
import { PuppeteerBase } from './PuppeteerBase';
export class PuppeteerListen extends PuppeteerBase {
    /**
     * 监听是否发起请求
     * @param URL 监听的请求
     */
    isResquest(URL: string) {

        this.Page.on('request', req => {
            if (req.url() === URL) {
            }
        })
    }

    /**
     *监听响应 
     * @param URL 
     */
    async isResponse(URL: string) {
        this.Page.on('response', resp => {
            if (resp.url() === URL) {
                if (resp.status() != 200) {
                }
            }
        })
    }

    /**
     * 请求失败
     */
    async isRequestFailed(URL: string) {
        this.Page.on('requestfailed', req => {
            if (req.url() === URL) {
            }
        })
    }

    /**
     *监听所有请求 
     */
    getAllRequest() {
        let All = []
        this.Page.on('request', req => {
            All.push(req.url())
        })
        return All;
    }
}